import java.util.HashMap;
import java.util.Map;

public class Solution1725 {
    public int countGoodRectangles(int[][] rectangles) {
        Map<Integer,Integer> map=new HashMap<>();
        int max=-1;
        for (int[] rectangle : rectangles) {
            int m=Math.min(rectangle[0],rectangle[1]);
            map.put(m,map.getOrDefault(m,0)+1);
            max=Math.max(max,m);
        }
        return map.get(max);
    }

    public static void main(String[] args) {
        System.out.println(new Solution1725().countGoodRectangles(new int[][]{{5,8},{3,9},{5,12},{16,5}}));
    }
}
